home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / Source / MSG Demo 1.2 Source / MSG Demo ƒ / MSG Shell ƒ / msg integrity.c < prev    next >
Text File  |  1993-11-10  |  2KB  |  80 lines

  1. /**********************************************************************\
  2.  
  3. File:        msg integrity.c
  4.  
  5. Purpose:    This module implements a quick-and-dirty integrity check;
  6.             compare the resource fork and map length to stored values.
  7.             (Drop the completed application on "Prepare" to store
  8.             these values in the right place.)
  9.  
  10. MSG Demo -- graphic effects demonstration program
  11. Copyright (C) 1992-3 Mark Pilgrim & Dave Blumenthal
  12.  
  13. This program is free software; you can redistribute it and/or modify
  14. it under the terms of the GNU General Public License as published by
  15. the Free Software Foundation; either version 2 of the License, or
  16. (at your option) any later version.
  17.  
  18. This program is distributed in the hope that it will be useful,
  19. but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21. GNU General Public License for more details.
  22.  
  23. You should have received a copy of the GNU General Public License
  24. along with this program in a file named "GNU General Public License".
  25. If not, write to the Free Software Foundation, 675 Mass Ave,
  26. Cambridge, MA 02139, USA.
  27.  
  28. \**********************************************************************/
  29.  
  30. #include "msg integrity.h"
  31. #include "msg graphics.h"
  32. #include "msg dialogs.h"
  33.  
  34. void DoIntegrityCheck(void)
  35. {
  36.     int                thisFile;
  37.     long            count;
  38.     long            resDataLength, checkData;
  39.     long            resMapLength, checkMap;
  40.     Boolean            problem;
  41.     
  42.     problem=FALSE;
  43.     FlushVol(0L, 0);
  44.     OpenRF(CurApName, 0, &thisFile);
  45.     if (!problem)
  46.     {
  47.         SetFPos(thisFile, 1, 8L);
  48.         count=4L;
  49.         problem=(FSRead(thisFile, &count, (Ptr)(&resDataLength))!=noErr);
  50.     }
  51.     if (!problem)
  52.     {
  53.         SetFPos(thisFile, 1, 12L);
  54.         count=4L;
  55.         problem=(FSRead(thisFile, &count, (Ptr)(&resMapLength))!=noErr);
  56.     }
  57.     if (!problem)
  58.     {
  59.         SetFPos(thisFile, 1, 144L);
  60.         count=4L;
  61.         problem=(FSRead(thisFile, &count, (Ptr)(&checkData))!=noErr);
  62.     }
  63.     if (!problem)
  64.     {
  65.         SetFPos(thisFile, 1, 148L);
  66.         count=4L;
  67.         problem=(FSRead(thisFile, &count, (Ptr)(&checkMap))!=noErr);
  68.     }
  69.     
  70.     if (!problem)
  71.         problem=((resDataLength!=checkData) || (resMapLength!=checkMap));
  72.  
  73.     if (problem)
  74.     {
  75.         PositionDialog('ALRT', integrityCheckFailAlert);
  76.         StopAlert(integrityCheckFailAlert,0L);
  77.         ExitToShell();
  78.     }
  79. }
  80.